package com.java.tools.mouse.e1;

import org.apache.commons.lang.Validate;

import java.awt.*;
import java.awt.event.InputEvent;

/**
 * 使用java代码实现鼠标的点击
 * @author wangning
 * @create 2022-03-18 14:30
 */
public class TestMouse {
	public static void main(String[] args) throws Exception {
		Robot robot = new Robot();
//		robot.delay(3000);
		//由于鼠标抖动，会导致当前坐标出现误差，可以进行多次定位
		int i = 10;
		while (i-- > 0) {
			robot.mouseMove(250, 350);
		}
		robot.delay(100);
		robot.mousePress(InputEvent.BUTTON1_DOWN_MASK);
		i = 10;
		while (i-- > 0) {
			robot.mouseMove(450, 350);
		}
		robot.delay(100);

		i = 10;
		while (i-- > 0) {
			robot.mouseMove(450, 550);
		}
//		robot.delay(100);
		i = 10;
		while (i-- > 0) {
			robot.mouseMove(250, 550);
		}
//		robot.delay(100);
		i = 10;
		while (i-- > 0) {
			robot.mouseMove(250, 350);
		}
		robot.mouseRelease(InputEvent.BUTTON1_DOWN_MASK);



	}
}
